package com.ntu.rent.common.util;

import java.sql.Timestamp;

import com.google.gson.Gson;
import com.ntu.rent.common.typeadapter.SqlDateTypeAdapter;
import com.ntu.rent.common.typeadapter.SqlTimestampTypeAdapter;
import com.ntu.rent.common.typeadapter.UtilDateTypeAdapter;

public class GsonBuilder
{
	private static Gson gson;
	
	private GsonBuilder(){}
	
	public static Gson create()
	{
		if(gson==null)
		{
			gson = new com.google.gson.GsonBuilder()
					.registerTypeAdapter(Timestamp.class, new SqlTimestampTypeAdapter())
					.registerTypeAdapter(java.util.Date.class, new UtilDateTypeAdapter())
					.registerTypeAdapter(java.sql.Date.class, new SqlDateTypeAdapter())
					.create();
		}
		return gson;
	}
}
